package org.etlt.check;

import org.etlt.job.JobContext;

public class V2VCheckPoint extends CheckPoint {

    public V2VCheckPoint(CheckPointSetting setting, CheckList checkList) {
        super(setting, checkList);
    }

    public CheckResult check(JobContext context) {
        CheckResult checkResult = new CheckResult(this);
        CheckPointSetting setting = getSetting();
        if (setting.getExpected().equals(setting.getActual()))
            checkResult.success();
        else
            checkResult.fail();
        return checkResult;
    }

    @Override
    public String getDetail(JobContext context) {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(getCheckList().getName())
                .append(".")
                .append(getName());
        stringBuilder.append(CR);
        stringBuilder.append("description: " + normalize(getSetting().getDescription()));
        stringBuilder.append(CR);
        stringBuilder.append("expected: " + getSetting().getExpected());
        stringBuilder.append(CR);
        stringBuilder.append("actual: " + getSetting().getActual());
        return stringBuilder.toString();
    }
}
